import { createRouter, createWebHistory } from 'vue-router'
import Index from '../views/Index.vue'
import BusinessList from '../views/BusinessList.vue'
import BusinessInfo from '../views/BusinessInfo.vue'
import Login from '../views/Login.vue'
import Orders from '../views/Orders.vue'

//Vue.use(VueRouter)


const routes = [
  {
    path: '/',
    name: 'home',
    component: Index
  }, {
    path: '/index',
    name: 'Index',
    component: Index
  },
  {
    path: '/businessList',
    name: 'BusinessList',
    component:  BusinessList
  },
  {
    path: '/businessInfo',
    name: 'BusinessInfo',
    component: BusinessInfo
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/orders',
    name: 'Orders',
    component: Orders
  }
]

//解决重复路由报异常问题
/*
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
  */


// 创建路由实例
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL), // Vite 项目用法
  // 如果是 vue-cli 项目，改为：createWebHistory(process.env.BASE_URL)
  routes
})

export default router
